<form method="post" id="frmOccupation" name="frmOccupation" action="{$smarty.const.HOST_VFRIEND}account/basicsave" enctype="multipart/form-data">
    <input type="hidden" name="ptsave" id="ptsave" value="{$intType}" />
	<div class="editForm">    	
        <div class="userInput">
        	<label>Nghề nghiệp:</label>
            <div class="pOccupation">
                <select class="select" id="poccupation" name="poccupation" {if $objUser->occupation == 0}title="Chọn"{/if} onchange="showOther(this.value)">
                	<option value="0">Chọn</option>
                    {if isset($smarty.session.st_occupation) && $smarty.session.st_occupation == -1}
                    	{html_options options=$arrOccupation}
                    	<option value="-1" selected="selected">Khác</option>
                    {else}
                		{html_options options=$arrOccupation selected=$objUser->occupation}
                    	<option value="-1">Khác</option>
                    {/if}
                </select>                
           	</div>
            <div class="secOther" {if isset($smarty.session.st_occupation) && $smarty.session.st_occupation == -1}style=""{else}style="display:none;"{/if}>
            	<input type="text" name="poccupation_other" id="poccupation_other" maxlength="150" value="{if isset($smarty.session.st_occupation_other)}{$smarty.session.st_occupation_other|escape}{/if}" class="text clearIt tMargin10" />
            </div>
        </div>
        <div class="userInput">
        	<input type="submit" value="Thay đổi" class="btnSubmit" />
            <input type="button" value="Hủy" class="btnCancel" onclick="javascript:basicClose('{$strView}','{$strEdit}')" />
        </div>
    </div>
</form>
<script type="text/javascript" language="javascript" src="{$smarty.const.HOST_STATICS}js/library/init.js"></script>
{literal}
<script type="text/javascript" language="javascript">
	$(document).ready(function(){		
		$("#frmOccupation").validate({							
			errorClass		: "errorMessage",
			errorElement	: "span",
			onfocusout		: false,
			onkeyup			: false,
			rules: {	
				poccupation:{
					required	: true,
					min			: 1
				},
				poccupation_other: {
					otherRequired	: true,
					otherMinlength	: true
				}
				
			},
			messages: {	
				poccupation:{
					required	: occupation_required,
					min			: occupation_required
				},
				poccupation_other: {
					otherRequired	: occupation_other_required,
					otherMinlength	: occupation_other_minlength
				}
			},	
			errorPlacement: function(label, element) {			
				var id = element.attr("id");			
				label.insertAfter($("#" + id));			
			},
			submitHandler: function(form) {				
				form.submit();
			}
		});	
		$.validator.addMethod("otherRequired",function(){
			var occupation = $("#poccupation").val();
			if(occupation == -1) {
				var occupationOther = $("poccupation_other").val();
				if(occupationOther == "") {
					return false;
				}
			}
			return true;
		});	
		$.validator.addMethod("otherMinlength",function(){
			var occupation = $("#poccupation").val();
			if(occupation == -1) {
				var occupationOther = $("poccupation_other").val();
				if(occupationOther != "" && occupationOther.length < 5 ) {
					return false;
				}
			}
			return true;
		});		
	});
	showOther = function(intValue) {
		if(intValue == -1) {
			$(".secOther").show();
		}
		else {
			$(".secOther").hide();
		}
	}
</script>
{/literal}